#ifndef __CATSMANAGER_H__
#define __CATSMANAGER_H__

#include "cocos2d.h"
#include "Supporting/Singleton.h"

class Character;
class GameMap;
class CatSpawnScript;
class CatSpawnSet;
class BaseCat;
class FatCat;
class GameManager;

class CatsManager: public Singleton<CatsManager>
{
private:
	//============= REFERENCES =============
	GameMap* 		_pMapRef;
	Character* 		_pCharRef;
	GameManager* 	_pGmRef;

	//============= SPAWN variable and functions =============
	CatSpawnScript* 	_pSpawnScript;
	CatSpawnScript* 	_pDirectorSpawnScript; //for ai director insertion

	void runSpawnScript(CatSpawnScript* script, float timeDiff);

	//============= CAT variables and functions =============
	cocos2d::CCArray* 	_cats; //reference to all the cat spawned
	cocos2d::CCArray*	_addCats; //reference to additional cats to spawn

	void removeDeadCats();
	void updateAllCats(float timeDiff);
	void addAdditionalCats();
	BaseCat* createCat(int catType);

	//============= OTHERS =============
	int 				_levelType;

	static const float	INIT_DIRECTOR_VALUE = -1.0;
	float				_directorObstacleHitChance;
	float				_directorSpeedMultiplier;

public:
	//========== CONSTRUCTOR ==========
	CatsManager(); //do not use
	void init(int levelType, GameMap* pMapRef, Character* pCharRef, GameManager* pGmRef);
	//========== DESTRUCTOR ==========
	~CatsManager(void);

	//========== FUNCTIONS ==========
	void update(float timeDiff);
	int checkCatTouchCollision(cocos2d::CCPoint location);
	int damageAllSwipedCats();
	void addCat(BaseCat* cat);

	//========== GETTERS / SETTERS ==========
	void setLevelSpawnScript(CatSpawnScript* pCatSpawnScript);
	void insertDirectorSpawnSet(CatSpawnSet* pCatSpawnSet);
	void updateDirectorObstacle(float obstacleHitChance);
	void updateDirectorSpeed(float speedMultiplier);

	cocos2d::CCArray* returnCats() { return _cats; };


};

#endif // __CATSMANAGER__
